import axios from 'axios'

export default {
    namespaced: true,
    actions: {
        getAllPlate: function ({commit},params) {
            let {callback} = params;
            params.onget = ({plates})=>{
                callback(plates)
            }
            commit("getAll",params)
        },
        getPlate: function ({commit},params) {
            let {callback} = params;
            params.onget = ({plate}) =>{
                callback(plate);
            }

            commit("getPlate",params)
        },
    },
    mutations: {
        getAll: function (state, {categoryId,name,userIds,view,page=0,size=4,onget}) {
            axios.get('/plate',
                {
                    params: {
                        categoryId, name, userIds, view, page, size
                    }
                }).then(({data}) => {
                onget(data);
            });
        },

getPlate: function (state, {id, onget}) {
            axios.get("/plate/" + id).then(({data}) => {
                onget(data);
            });
        },
    }

}